function []=plot_PTA(ROIs,aux_data,frame_times,MPboundary)
% this function plots the purturbation triggered average response of all
% cells

win_l=500;
win_r=2000;

ps_time=find(diff(aux_data(1,:)>0.5)==1)+1;

ps_time_M=ps_time(ps_time<MPboundary);
ps_time_P=ps_time(ps_time>MPboundary);

aux_data_length=length(aux_data);
PTA_M_all=zeros(win_l+win_r,length(ROIs));
PTA_P_all=zeros(win_l+win_r,length(ROIs));

for knd=1:length(ROIs)
    roi_act=map_ROI_act_to_aux_data(ROIs(knd).activity,frame_times,aux_data_length);
    
    PTA_M=zeros(win_l+win_r,length(ps_time_M));
    for ind=1:length(ps_time_M)
        PTA_M(:,ind)=roi_act(ps_time_M(ind)-win_l:ps_time_M(ind)+win_r-1);
    end
    
    PTA_P=zeros(win_l+win_r,length(ps_time_P));
    for ind=1:length(ps_time_P)
        PTA_P(:,ind)=roi_act(ps_time_P(ind)-win_l:ps_time_P(ind)+win_r-1);
    end

    PTA_M_all(:,knd)=mean(PTA_M')-mean(mean(PTA_M));
    PTA_P_all(:,knd)=mean(PTA_P')-mean(mean(PTA_P));
end




figure;
axes('position',[0 0 0.5 1])
imagesc(PTA_M_all')

axes('position',[0.5 0 0.5 1])
imagesc(PTA_P_all')